#ifndef _STRAWGUI_TEXTURE_RESOURCE_FRAME_H_
#define _STRAWGUI_TEXTURE_RESOURCE_FRAME_H_

#include "sNamedObject.h"
#include "sTransform.h"
#include "sLinkTo.h"
#include "sTRModule.h"
#include "sStretch.h"
#include <deque>

namespace sgui
{
namespace engine
{
	class sRenderTarget;
};
namespace res
{    

	class sTextureResourceFrame : public sNamedObject
	{
	public:		
		class sFrameObject : public sGUIObject
	#ifdef _EDITOR
		, public rtti::sObject
	#endif
		{
		private:
			sLinkTo<sTextureResourceModule>		m_module;
			obj::sTransform						m_transform;
		public:
			sLinkTo<sTextureResourceModule>&	getModule();
			obj::sTransform&					getTransform();
		
			void load(const db::Record &file);
			void save(db::Record &file) const;
			void clear();

	#ifdef _EDITOR
			void exportRTTI(rtti::sInfoList& list);
	#endif
			sFrameObject(sGUI& gui);
			sFrameObject(sGUI& gui, sTextureResourceModule* module);
		};

	private:
		std::deque<sFrameObject*>	m_objects;
		math::sPointf				m_surfaceSize;
		engine::sRenderTarget*		m_renderTarget;
		sStretch					m_stretch;
	public:
		const sStretch& getStretch() const { return m_stretch; }
		sStretch& getStretch() { return m_stretch; }

		void load(const db::Record &file);
		void save(db::Record &file) const;
        void clear();

		std::deque<sFrameObject*>& getObjects();
		const std::deque<sFrameObject*>& getObjects() const;

		void draw(engine::sDrawStack& drawStack, const math::sRectf& rect) const;
		void setSize(const math::sPointf& size);
		void update();

#ifdef _EDITOR
		void exportRTTI(rtti::sInfoList& list);
#endif

		sTextureResourceFrame(sGUI& gui, const std::wstring& name);
        ~sTextureResourceFrame();
	};

};
};

#endif